package tester;

import fiziksobject.FiziksBall;
import physics.Location;
import physics.PhysicsEngine;
import physics.Vector;
import physics.physicsobject;

public class CollisionTester {
	public static void main(String[] args) {
		FiziksBall b1 = new FiziksBall(1.0, 0.0, new Vector(new Location(1, 1),
				Vector.Type.MOMENTUM, 30.0, -2.0), new Location(0, 2),Math.sqrt(2));
		FiziksBall b2 = new FiziksBall(1.0, 0.0, new Vector(
				new Location(2, 0), Vector.Type.MOMENTUM, -15.0, 1.0),
				new Location(2, 0), Math.sqrt(2));
		Vector mi1 = b1.getMomentum();
		System.out.println("Initial Velocity of b1 "+ mi1.divide(b1.getMass()));
		Vector mi2 = b2.getMomentum();
		System.out.println("Initial Velocity of b2 "+ mi2.divide(b2.getMass()));
		Vector im = mi1.add(mi2);
		System.out.println("Initial Net Momentum " + im);
		System.out.println("Initial Net Energy " + (.5 * b1.getMass()
				* Math.pow(mi1.divide(b1.getMass()).getNetMag(), 2) + .5
				* b2.getMass()
				* Math.pow(mi2.divide(b2.getMass()).getNetMag(), 2)));
		Vector mf1 = b1.getNormalForce(b2).multiply(PhysicsEngine.TIMESTEP);
		 System.out.println("Force on b1 " +mf1);
		Vector mf2 = b2.getNormalForce(b1).multiply(PhysicsEngine.TIMESTEP);
		System.out.println("Force on b2 " +mf2);
		b1.applyForce(mf1);
		b2.applyForce(mf2);
		mf1 = b1.getNewmomentum();
		mf2 = b2.getNewmomentum();
		System.out.println("Final Velocity of b1 "+ mf1.divide(b1.getMass()));
		System.out.println("Final Velocity of b2 "+ mf2.divide(b2.getMass()));


		System.out.println("Final Net Momentum " + mf1.add(mf2).toString());
		System.out.println("Final Net Energy " + (.5 * b1.getMass()
				* Math.pow(mf1.divide(b1.getMass()).getNetMag(), 2) + .5
				* b2.getMass()
				* Math.pow(mf2.divide(b2.getMass()).getNetMag(), 2)));

	}
}
